

const path = require('path');
const staticImg = path.join(__dirname, 'static');

function ArduinoUnoBlocks(Blockly) {
    var color_display = "#f59057";



   //8x8点阵屏初始化
Blockly.Blocks.ph_max = {
    init:function(){
    this.setColour(color_display);
    this.appendDummyInput("")
     .appendField(new Blockly.FieldImage(staticImg+"/24. 8x8.svg", 84, 42))
       .appendField(Blockly.Msg.PH_MAX)
       .appendField(new Blockly.FieldDropdown([
         ['D2', "2"],
         ['D3', "3"],
         ['D4', "4"],
         ['D5', "5"],
         ['D6', "6"],
         ['D7', "7"],
         ['D8', "8"],
         ['D9', "9"],
         ['D10', "10"],
         ['D11', "11"],
         ['D12', "12"],
         ['D13', "13"],
         ['A0', "14"],
         ['A1', "15"],
         ['A2', "16"],
         ['A3', "17"],
         ['A4', "18"],
         ['A5', "19"]
       ]),"din")
       .appendField(Blockly.Msg.PH_CS)
       .appendField(new Blockly.FieldDropdown([
        ['D2', "2"],
        ['D3', "3"],
        ['D4', "4"],
        ['D5', "5"],
        ['D6', "6"],
        ['D7', "7"],
        ['D8', "8"],
        ['D9', "9"],
        ['D10', "10"],
        ['D11', "11"],
        ['D12', "12"],
        ['D13', "13"],
        ['A0', "14"],
        ['A1', "15"],
        ['A2', "16"],
        ['A3', "17"],
        ['A4', "18"],
        ['A5', "19"]
       ]),"cs")
       .appendField(Blockly.Msg.PH_CLK)
       .appendField(new Blockly.FieldDropdown([
        ['D2', "2"],
        ['D3', "3"],
        ['D4', "4"],
        ['D5', "5"],
        ['D6', "6"],
        ['D7', "7"],
        ['D8', "8"],
        ['D9', "9"],
        ['D10', "10"],
        ['D11', "11"],
        ['D12', "12"],
        ['D13', "13"],
        ['A0', "14"],
        ['A1', "15"],
        ['A2', "16"],
        ['A3', "17"],
        ['A4', "18"],
        ['A5', "19"]
       ]),"clk")
        .appendField(Blockly.Msg.PH_MAXS)
       this.appendValueInput("maxs", Number)
    this.setPreviousStatement(true,null);
      this.setNextStatement(true,null);
    this.setTooltip('');
    }
    };
    
    //8x8点阵屏单点亮或灭
    Blockly.Blocks.ph_maxpoint = {
    init:function(){
    this.setColour(color_display);
    this.appendDummyInput("")
     .appendField(new Blockly.FieldImage(staticImg+"/24. 8x8.svg", 84, 42))
    
    
     .appendField(Blockly.Msg.PH_MAXPRINT)
     .appendField(new Blockly.FieldDropdown([
      ['0', "0"],
      ['1', "1"],
      ['2', "2"],
      ['3', "3"],
      ['4', "4"],
      ['5', "5"],
      ['6', "6"],
      ['7', "7"],
      ['8', "8"],
      ['9', "9"],
      [Blockly.Msg.PH_MSMILE, "10"],
      [Blockly.Msg.PH_MBIGSMILE, "11"],
      [Blockly.Msg.PH_MHAHA, "12"],
      [Blockly.Msg.PH_MHEART, "13"],
      [Blockly.Msg.PH_MSURPRISE, "14"],
      [Blockly.Msg.PH_MLITTLESURPRISE, "15"],
      [Blockly.Msg.PH_MTONE, "16"],
      [Blockly.Msg.PH_MTOOTH1, "17"],
      [Blockly.Msg.PH_MTOOTH2, "18"],
      [Blockly.Msg.PH_MLINE, "19"],
      [Blockly.Msg.PH_MCONFUSED, "20"],
      [Blockly.Msg.PH_MLINE2, "21"],
      [Blockly.Msg.PH_MSAD1, "22"],
      [Blockly.Msg.PH_MSAD2, "23"],
      [Blockly.Msg.PH_MSAD3, "24"],
      ['√', "25"],
      ['×', "26"],
      ['?', "27"],
      [Blockly.Msg.PH_MLIGHT, "28"],
      [Blockly.Msg.PH_MMOUTH, "29"],
      [Blockly.Msg.PH_MMAD, "30"],
     ]),"draw")
    
    
    this.setPreviousStatement(true,null);
      this.setNextStatement(true,null);
    this.setTooltip('');
    }
    };
    //8x8点阵屏点选
    Blockly.Blocks.ph_x8leddisplay = {
      init:function(){
      this.setColour(color_display);
      this.appendDummyInput("")
       .appendField(new Blockly.FieldImage(staticImg+"/24. 8x8.svg", 84, 42))
         .appendField(Blockly.Msg.PH_X8LEDDISPLAY)
         .appendField(new Blockly.LatticeAdapter(),"draws")
    
         this.setPreviousStatement(true,null);
           this.setNextStatement(true,null);
         this.setTooltip('');
       }
    };
    
      

    return Blockly;
}

module.exports = ArduinoUnoBlocks;

